<template>
  <teleport to="body">
    <div class="shower-screen" v-if="dialogVisible" @click.self="emits('close')">
      <div ref="draggableElement" :class="['draggable-container', size == 'small' ? 'small' : '']">
        <div class="draggable-title">{{ title }}</div>
        <div class="close" @click.stop="closeDialog"></div>
        <div class="tconten">
          <slot></slot>
        </div>
      </div>
    </div>
  </teleport>
</template>  
    <script setup>
import { ref, defineProps, defineEmits } from 'vue'
import { useDraggable } from '../hook/useDraggable'
const props = defineProps({
  title: {
    type: String,
    default: '标题'
  },
  size: {
    type: String,
    default: 'big'
  },
  dialogVisible: {
    type: Boolean,
    default: false
  }
})

const emits = defineEmits(['close'])
const draggableElement = ref(null)
useDraggable(draggableElement)

const closeDialog = () => {
  emits('close')
}
</script>  
      
    <style scoped>
.shower-screen {
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  padding-top: 10vh;
  background-color: #2c2f337a;
  height: 100vh;
  width: 100vw;
  z-index: 2000;
}

.draggable-container {
  height: 290px;
  width: 450px;
  background-image: url(/static/icon/chart.png);
  background-size: 100% 100%;
  color: #ffffff;
  position: relative;
}
.small {
  height: 200px;
  background-image: url(/static/icon/textdialog.png);
}
.draggable-title {
  cursor: grab;
  user-select: none;
  height: 35px;
  line-height: 35px;
  padding-left: 35px;
}

.tconten {
  height: calc(100% - 35px);
  padding: 8px 20px;
  box-sizing: border-box;
}
.small .tconten {
  overflow: auto;
  font-size: 16px;
}
.close {
  position: absolute;
  right: 9px;
  top: 9px;
  width: 20px;
  height: 20px;
  cursor: pointer;
}
</style>